package com.tencent.backstage.service.impl;

import com.tencent.backstage.dao.SuggestDao;
import com.tencent.backstage.entity.Suggest;
import com.tencent.backstage.service.SuggestService;
import com.tencent.backstage.vo.SuggestPageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SuggestServiceImpl implements SuggestService {
    @Autowired
    private SuggestDao suggestDao;
    @Override
    public SuggestPageVO findAll(Pageable pageable) {
        Sort sort = new Sort(Sort.Direction.DESC,"createTime");   //降序----根据创建时间来进行降序
        PageRequest request = new PageRequest(pageable.getPageNumber(),pageable.getPageSize(),sort);  //第0页，取一条
        Page<Suggest> eventPage = suggestDao.findAll(request);
        SuggestPageVO suggestPageVO = new SuggestPageVO();
//        suggestPageVO.setSuggestList(eventPage.getContent());
//        suggestPageVO.setTotalPage(eventPage.getTotalPages());
        return suggestPageVO;
    }
}
